using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySQL_SysFrameMVC.Message;
using System.Reflection;
using SysFrame.BP;
using SysFrame.Message;
using TaskAPP.Message;

namespace TaskApp.BP
{
    /// <summary>
    /// taskapp_c1方法
    /// </summary>
    public class BLLtaskapp_c1
    {
        public Itaskapp_c1 interface_taskapp_c1;
        private BLLtaskapp_main bLLtaskapp_main;

        public BLLtaskapp_c1()
        {
            object obj = BPBase.GetAchieve("TaskApp.BP", "taskapp_c1");
            interface_taskapp_c1 = (Itaskapp_c1)obj;
        }

        public BLLtaskapp_c1(BLLtaskapp_main bLLtaskapp_main)
        {
            object obj = BPBase.GetAchieve("TaskApp.BP", "taskapp_c1");
            interface_taskapp_c1 = (Itaskapp_c1)obj;
            bLLtaskapp_main.valiT += new BLLtaskapp_main.valiTask(valiTask);
        }


        /// <summary>
        /// 得到taskapp_c1实体
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns></returns>
        public List<Mstaskapp_c1> Gettaskapp_c1MsByQuery(MsQuery msq)
        {
            return interface_taskapp_c1.Gettaskapp_c1MsByQuery(msq);
        }


        /// <summary>
        /// 通过TASKAPP_C1_AUTOID得到实体
        /// </summary>
        /// <param name="TASKAPP_C1_AUTOID">ID</param>
        /// <returns>实体</returns>
        public Mstaskapp_c1 Gettaskapp_c1MsByKey(string TASKAPP_C1_AUTOID)
        {
            MsQuery msquery = new MsQuery();
            msquery.strquery += " and TASKAPP_C1_AUTOID='" + TASKAPP_C1_AUTOID + "' ";
            List<Mstaskapp_c1> lstData = Gettaskapp_c1MsByQuery(msquery);
            Mstaskapp_c1 ms = lstData[0];
            ms = BLLtaskapp_main.GetTaskMainMsg<Mstaskapp_c1>( ms.ToJObject());
            return ms;
        }

        /// <summary>
        ///  保存taskapp_c1信息
        /// </summary>
        /// <param name="ms">实体信息</param>
        /// <returns>消息</returns>
        public MsReturned Savetaskapp_c1(Mstaskapp_c1 ms)
        {
            return interface_taskapp_c1.Savetaskapp_c1(ms);
        }

        /// <summary>
        /// 得到数据类型
        /// </summary>
        /// <param name="msquery">条件</param>
        /// <returns>数据类型</returns>
        public MsReturned Gettaskapp_c1ByQuery(MsQuery msquery)
        {
            return interface_taskapp_c1.Gettaskapp_c1ByQuery(msquery);
        }

        /// <summary>
        /// 删除taskapp_c1
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns></returns>
        public MsReturned Deletetaskapp_c1ByQuery(MsQuery msq)
        {
            return interface_taskapp_c1.Deletetaskapp_c1ByQuery(msq);
        }
        /// <summary>
        /// 删除taskapp_c1
        /// </summary>
        /// <param name="msq">条件</param>
        /// <returns></returns>
        public MsReturned Deletetaskapp_c1ByKey(string TASKAPP_C1_AUTOID)
        {
            MsQuery msquery = new MsQuery();
            
             if (TASKAPP_C1_AUTOID.IndexOf(",") > 0)
            {
                msquery.strquery += " and TASKAPP_C1_AUTOID in (" + TASKAPP_C1_AUTOID + ") ";
            }
            else
            {
                msquery.strquery += " and TASKAPP_C1_AUTOID='" + TASKAPP_C1_AUTOID + "' ";
            }
            return interface_taskapp_c1.Deletetaskapp_c1ByQuery(msquery);
        }

        /// <summary>
        /// 验证调拨单
        /// </summary>
        /// <param name="id">单据ID</param>
        /// <returns></returns>
        MsReturned valiTask(string id)
        {
            MsReturned msr = new MsReturned();
            Mstaskapp_c1 msc1 = Gettaskapp_c1MsByKey(id);
            //并没有什么好判断的
            msr.strMsId = "1";
            msr.data = msc1.ToJObject();
            return msr;
        }
    }
}
